import os
from Tkinter import *
root = Tk()
root.title("Maverick v 0.0.0.2_GUI")
g = 0 
def Print(a) :
    c = "\n"+a
    text.insert(INSERT,c)
a = """HELLO"""
d = None

scrollbar = Scrollbar(root)
scrollbar.pack( side = RIGHT, fill=Y )

text = Text(root,yscrollcommand = scrollbar.set )
L1 = Label(root , text = "INPUT")
E1 = Entry(root,bd = 2,width = 100)
def Copy(y):
    global g
    b = "\n"+"   "+E1.get()
    say = E1.get()
    if g <= 2 :
        g += 1
    text.insert(INSERT,b)
    E1.delete(0,len(E1.get()))
    if g == 1 :
        if say == 'hello' or say == 'Hello'  :
            Print('My name is Maverick')
            Print("What's your's ")
        else :
            Print("I did'nt understood what you said")
            Print('My name is Maverick')
            Print("What's your's ")
    if g == 2 :
        b = say.find('my name is')
        c = say.find('My name is')
        if b != -1 or c != -1 :
            name = str(say[11:])
        else :
            name = str(say)
        Print(('Hello'+" "+name))
        Print('What can I do for you ?')
    if g == 3 :
        if say[0:4] == 'play' or say[0:4] == 'Play':
            x = say[5:]
            b = "D:\Nikhil\Songs\\'x'"
            a = b.replace("'x'",x+'.mp3')
            os.startfile(a)
        Print('Now What ?')
E1.bind("<Return>",Copy)
text.insert(INSERT, a)
text.pack()
scrollbar.config( command = text.yview )
L1.pack(side = LEFT)
E1.pack(side = RIGHT)


root.mainloop()
